package com.Service.Impl;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.Dao.BaseDaoI;
import com.Entity.KnowledgeInfo;
import com.Service.KnowledgeServiceI;

@Service("knowledgeService")
public class KnowledgeServiceImpl extends BaseServiceImpl<KnowledgeInfo>
		implements KnowledgeServiceI {
	@Autowired
	private BaseDaoI<KnowledgeInfo> knowledgedao;

	private List<KnowledgeInfo> knowledgelist = new ArrayList<KnowledgeInfo>();

	@Override
	public List<KnowledgeInfo> findByFingerPrint(long fingerPrint) {
		// TODO Auto-generated method stub
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("fingerPrint", fingerPrint);
		String hql = "from KnowledgeInfo t where t.fingerPrint = :fingerPrint";
		knowledgelist = this.knowledgedao.find(hql, params);
		return knowledgelist;
	}

	@Override
	public List<KnowledgeInfo> findByCategoryId(short categoryId) {
		// TODO Auto-generated method stub
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("categoryId", categoryId);
		String hql = "from KnowledgeInfo where categoryId=:categoryId order by infoTime desc";
		knowledgelist = this.knowledgedao.find(hql, params);
		return knowledgelist;
	}

	@Override
	public List<KnowledgeInfo> findByKeyWords(String str) {
		// TODO Auto-generated method stub
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("str", "%" + str + "%");
		String hql = "from KnowledgeInfo where infoTitle like :str or nlpirKeyWords like :str order by infoTime desc";
		knowledgelist = this.knowledgedao.find(hql, params);
		return knowledgelist;
	}

}
